import request from "../utils/request";
import { Info,TheWord,practice } from "../type";
// 登录接口
export function login(info:Info){
	return request({
		url:'/v1/front/login',
		method:'POST',
		data:{
			info:info
		}
	})
}

// 获取下拉列表选项
export function getOption(){
	return request({
		url:'/v1/front/getOptions',
		method:'GET',
	})
}
// 根据名字获取单词组
export function GetList(e:string){
	return request({
		url:`/v1/front/getWord?name=${e}`,
		method:'GET'
	})
}

// 获取随即单词
export function getRandomWord(words:practice[]):practice{
	// console.log(words)
    const index:number=Math.floor(Math.random() *words.length);
    return words[index]
}
// 初始化单词数据
export  function InitPractice(words:TheWord[]):practice[]{
    let practice:practice[] = []
    words.forEach(e => {
        const pra:practice={word:e,score:5}
        practice.push(pra)
    });

    return practice
}

